package com.ddzh.web;

import com.ddzh.entity.Result;
import com.ddzh.pojo.Menu;
import com.ddzh.pojo.Role;
import com.ddzh.service.MenuService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menuController")
public class MenuController {

    @Reference
    private MenuService menuService;

//    @GetMapping("/getMenuTree")
//    public Result getMenuTree(){
//        return new Result(menuService.getMenuTree());
//    }

    @GetMapping("/findAll")
    public Result findAll(){
        List<Menu> list = menuService.list();
        return new Result(menuService.list());
    }

    @GetMapping("/getMenuTree")
    public Result getMenuTree(){
        System.out.println("web获取到的****"+ RpcContext.getContext().getAttachment("currentUser"));
        return new Result(menuService.getUserMenuTrees());
    }


}
